//
//  CXTabBarViewController.m
//  weico
//
//  Created by c_xie on 15-4-9.
//  Copyright (c) 2015年 c_xie. All rights reserved.
//

#import "CXTabBarViewController.h"
#import "CXDiscoverViewController.h"
#import "CXHomeViewController.h"
#import "CXMessageViewController.h"
#import "CXProfileViewController.h"

@interface CXTabBarViewController ()

@end

@implementation CXTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupChildVc];
    
}

- (void)setupChildVc
{
    [self addChildVCWithSBName:@"CXHome" title:@"首页" imageName:@"tabbar_home" selectImageName:@"tabbar_home_highlighted"];
    [self addChildVCWithSBName:@"CXMessage" title:@"消息" imageName:@"tabbar_message_center" selectImageName:@"tabbar_message_center_highlighted"];
    [self addChildVCWithSBName:@"CXDiscover" title:@"发现" imageName:@"tabbar_discover" selectImageName:@"tabbar_discover_highlighted"];
    [self addChildVCWithSBName:@"CXProfile" title:@"我" imageName:@"tabbar_profile" selectImageName:@"tabbar_profile_highlighted"];
    
}


- (void)addChildVCWithSBName:(NSString *)SBName title:(NSString *)title imageName:(NSString *)imgName selectImageName:(NSString *)selectImgName
{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:SBName bundle:nil];
    UINavigationController *nav = sb.instantiateInitialViewController;
    // 只有栈顶控制器才能设置导航条的内容
    [self addChildVCWithControler:nav.topViewController title:title imageName:imgName selectImageName:selectImgName];
    
}

- (void)addChildVCWithControler:(UIViewController *)topVC title:(NSString *)title imageName:(NSString *)imgName selectImageName:(NSString *)selectImgName
{
    topVC.title = title;
    topVC.tabBarItem.image = [UIImage imageNamed:imgName];
    topVC.tabBarItem.selectedImage = [UIImage imageNamed:selectImgName];
    [self addChildViewController:topVC.navigationController];
}

@end
